<?php
// +----------------------------------------------------------------------
// | Description: 1
// +----------------------------------------------------------------------
// | Author: orchief
// +----------------------------------------------------------------------
// | Date: 2018-01-24 16:13:32
// +----------------------------------------------------------------------

namespace app\client\controller;

use app\common\controller\Common;
use EasyWeChat\Factory;

class Wechat extends Common
{
    public function menus()
    {
        $config = [
            'app_id' => config('wechat.app_id'),
            'secret' => config('wechat.secret'),
            // 指定 API 调用返回结果的类型：array(default)/collection/object/raw/自定义类名
            'response_type' => 'array',

            'log' => [
                'level' => 'debug',
                'file' => __DIR__ . '/wechat.log',
            ],
        ];

        $app = Factory::officialAccount($config);

        $buttons = [
            [
                "type" => "view",
                "name" => "首页",
                "url" => "http://wx.yingdun.com.cn/wx/home",
			],
            [
                "name" => "会员",
                "sub_button" => [
                    [
                        "type" => "view",
                        "name" => "登录",
                        "url" => "http://wx.yingdun.com.cn/wx/login",
                    ],
                    [
                        "type" => "view",
                        "name" => "注册",
                        "url" => "http://wx.yingdun.com.cn/wx/register",
                    ]
                ],
            ],
        ];
        $app->menu->create($buttons);
    }
}
